package com.micro.api.user.service.impl;

import com.micro.api.entity.User;
import com.micro.api.service.IUserService;
import com.micro.base.BaseApiService;
import com.micro.base.ResponseBase;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @title: UserServiceImpl
 * @Author: yzp
 * @Date: 2019/9/28 11:42
 * @Version 1.0
 */
@RestController
public class UserServiceImpl extends BaseApiService implements IUserService {

    @Value("${server.port}")
    private String serverPort;

    @Override
    @RequestMapping("/getUser")
    public User getUser(@RequestParam("name") String name) {
        User user = new User();
        user.setName(name + "端口号:" + serverPort);
        user.setAge(20);
        return user;
    }

    @Override
    @RequestMapping("/getUserInfo")
    public ResponseBase getUserInfo() {
        System.out.println(" 我是会员服务,会员服务调用订单服务开始啦！！");
        try {
            // 会员服务接口产生1.5秒的延迟
            Thread.sleep(1500);
        } catch (Exception e) {
            // TODO: handle exception
        }
        return setResultSuccess("订单服务接口调用会员服务接口成功....");
    }
}
